# # # buff1 = int(input("亲输入一个属："))
# # # buff2 = int(input("亲输入另一个属"))
# # # print(buff1 - buff2)
# #
# # """字符类型转换"""
# # buff1 = 1
# # print(float(buff1))
# # print(str(buff1))
# # buff2 = 1.33
# # print(int(buff2))
# # print(str(buff2))
# # buff3 = "a"
# # # print(int(buff3))不可转换
# # # print(float(buff3))
# # a = 0
# # print(bool(a))
# # print(type(bool))
#
# # a = """
# #                 望岳
# #         岱宗夫如何，齐鲁青未了
# #         造化钟神秀，阴阳割昏晓
# #         袒胸生层云，决眦入归鸟
# #         会当凌绝顶，一览众山小
# # """
# # print(a)
# a = '0'
# print(bool(a))
# a = bool(a)
# # a = int(a)
# print(type(a))
# 算数运算符:  + - * / % // **
# % 求余数  //整除  ** 算平方
# a = 6
# b = 4
# print(a + b)  # 10
# print(a - b)  # 2
# print(a * b)  # 24
# print(a / b)  # 1.5
# print(a % b)  # 2
# print(a // b)  # 1
# print(a ** b)  # a的b次方 1296
# import random
#
# a = random.randint(1, 100)
# """
# 关系运算符
# > < >= <= != == is
# """
# # A = 15
# # print(10 < A < 20)
# print(60 < a < 70)
"""#if 0

ture  and  ture  =  ture
ture  and  false =  false
false  and  ture = false
与一假为假

false  or  false = false
ture  or  false = ture
false  or  ture = ture
或 一真为真

a = 5
b = 3
print(a and b)# 3
print(b and a)# 5
print(0 and a)# 0
print(-1 and b)# 3
print(not a < b)# not 反转真假
print('-' * 10)
print(not a > b or a != 0)
a = "acdse"
c = input("亲输入账号：")
if a == c:
    print("yes")
else:
    print("NO")
#endif
#进制转换
# 转换为二进制 bin()  0bxxx
# a = 168
# count = bin(a)
# print(a)
#
# # 转为8进制 oct()  0oxxx
# count = oct(a)
# print(count)
#
# # 转换为16进制 hex()  0x xx
# count = hex(a)
# print(count)
# 十进制输出 int()
n = 0x558
count = int(n)
print("%d" % n)

count = bin(n)# erjingzhi
print(count)
count = hex(n)# shiliujingz
print(count)
# abs()jueduizhi
while n <= 50:
    if n % 3 ==0:
        print(n, end=' ')
    n += 1
n = 0
a = 10
print("ascf",a)
# print(a)
# a = "abcdef"
# 逻辑运算符  and  or  not
# A and B
count = 0
n = 0
while 1:
    count += float(input("亲输入购买的金额\n"))
    n += 1
    answer = input("是否继续购买 y/n\n")
    if answer == 'n':
        break
print("购买的总金额%.2f 总数目%d" % (count,n))
# 拆数字游戏
# 机器随机0 - 2   0
import random
ran = random.randint(0, 2)
per_count = 0asdf
r_count = 0
n = 3
while n > 0:
    guess = int(input("亲输入0（剪刀） 1（石头） 2（步）\n"))
    if (guess == 0 and ran == 2) or (guess == 1 and ran == 0) or (guess == 2 and ran == 1):
        print("you win\n")
        per_count += 1
    elif ran == 0 and guess == 1 or ran == 1 and guess == 0 or ran == 2 and guess == 1:
        print("robot win\n")
        r_count += 1
    else:
        print("a tie\n")
    n -= 1
if per_count > r_count:
    print("you win in end\n")
else:
    print("robot win\n")
# for 循环
# for i in rang(a,b,c) a是i的起始值 b是i的结束值，c是a一次加多少默认为1
#  a < b 结束
for i in range(1, 10, 3):
    print(i)
for i in range(0, 3):
    username = input("亲输入账号\n")
    userword = input("亲输入密码\n")
    if username == "hadage" and userword == "123000":
        print("登录成功\n")
        break
i = 0
if i == 2:
print(n)
    print("账号被锁\n")
"""

# 字母和数字组合
"""
if i in range()

else
    for没有被中断才会执行
for i in range(0, 3):
    username = input("亲输入账号\n")
    userword = input("亲输入密码\n")
    if username == "hadage" and userword == "123000":
        print("登录成功\n")
        break
else:
    print("被锁了\n")
n = 10
while n > 0:
    print(n)
    n -= 1
else:
    print("over")
#
# //掷色子 俩个
import random
count = 10 # 金币数、
start = 1
while start:
    start = int(input("要玩吗，一次俩金币，开局哥子大方送你10金币""\n""赢了给你3金币，按1开始 0退出 \n"))
    if start == 1:
        choice = input("10个不够吧，氪一点吧你(反正不要你钱ququ) (y/n)\n")
        if choice == 'y':
            recharge = int(input("现在活动0.8折，氪10得120金币\n"))
            count += recharge * 1.2
        print("金币数", count)
        # 设置奖励案例倍数
        factor = int(input("一倍的话就是奖励6个，二倍12个以此类推（扣的金币也是一样的哦)\n来吧>>"))
        factor += 1
        # 实现大小的判断 大是俩点数相加大于6 否者小
        while start == 1 and count >= 2:
            ran1 = random.randint(1, 6)
            ran2 = random.randint(1, 6)
            while 1:
                guess = input("亲输入你要拆的大小 (大 1 ；小 0) 886退出\n")
                if guess == '0' or guess == '1' or guess == '886':
                    break
            guess = int(guess)
            if guess == 886:
                break
            if ran1 + ran2 > 6 and guess == 1:
                print("点数为大，你猜对了\n奖励你", (3 * factor), "个金币")
                count += 3 * factor
            elif ran1 + ran2 <= 6 and guess == 0:
                print("点数为小，你猜对了\n奖励你 ", (3 * factor), "个金币")
                count += 3 * factor
            else:
                print("你猜错了点数为%d ，扣除你 %d 个金币" % ((ran1 + ran2), 2 * factor))
                count -= 2 * factor
            print("剩余金币数", count)

        if count < 2:
            print("没钱啦\n")
    else:
        print("游戏结束...")
        exit(0)
print("hhhh\nhhhh")
print("hhhh\thhhh")# \t 是一个tab
print("hhhh\\hhhh")
print("hhhh\"h")
# 映入地址、
a = "asdfgh"
print(id(a))
# 数组
print(a[2])
# 俩桃下标方式
# 从头开始0 1 2 3
# 从尾开始-1 -2 -3 -4
print("从头开始", a[0], "从尾开始", a[-1])
# :冒号 决定打印那些元素
print(a[:])
print("n", a[1:-1])# 打印中间
# print("❤❤ღღ💛💛💖💖♉")
# print("💋💋pyhton 你真的是超人💖💖")
# a = 10
# b= 20
# c = a + b

s = "ABCDEFG"
d = "ABCDEFG"
print(s[:])
print(s[2:-1])
print(id(d))
print(id(s))
print(s[-1:3:-4])
# s[start:end:step] step为正箭头从左往右 为负相反
#  字符串函数
# find 查找字符 是字符 也可以是字符串 若没有返回-1
path = "https://zhuanlan.zhihu.com/p/355438312"
i = path.find("zhihu")
j = path.find(("/p"))
print(path[:i])
# rfind 查找字符 但是是从右边开始
i = path.rfind(":")
print(path[i+1:])
#count 计算某个字符出现的次数 也可以字符串
i = path.count('zh')
print(i)
# index 和find一样只不过找不到会报错
i = path.index("z")
print(path[i:])
count = 0
print(path.count('/'))
while i != -1:
    i = path.find('/')
    path = path[i+1:]
    if i != -1:
        count += 1
print(count)
# 判读字符串长度
path = "https://zhuanlan.zhihu.com/p/355438312"
print(len(path))
import random

file = input("请输入文件名全程\n")
if file.endswith("png") or file.endswith("pif") or file.endswith("jpg"):
    name = file[:file.rfind('.')]
    ed = file[file.rfind('.'):]
    if len(name) > 6:
        print(file)
    else:
        name = str(random.randint(100000, 1000000))
    file = name + ed
    print(file)
else:
    print("error")
n = 0
while n != 10000:
    n = random.randint(0, 10000)
import random

name = ''
s = "qwertyuiopasdfghjklzxcvbnm1234567890"
for i in range(6):
    index = random.randint(0, len(s) - 1)
    name += s[index]
print(name)
# isalpha isdigit isspace isalnum islower isupper 判断是否是xxx bool类型的函数
# 判断的是整个字符串
s = "qwerta"
s1 = "234"
s2 = "244tj"
s3 = "@"
s4 = "As"
s5 = "aaaaa12345"
s6 = "DFGHJ67890"
print(s.isalpha())
print(s1.isdigit())
print(s3.isalnum())# 判断的是是否为数字字符或者是字母
print(s6.isupper())# 字符串中的字母是否全是大写
print(s5.islower())
3333333333333333333# 登录界面 输入用户名 全小写 首元素为字母 长度在6以上
# flag = 1
# while flag != 0:
#     name = input("亲输入账号\n")
#     if name.isalnum() and name[0].isalpha():
#         flag = 0
#     else:
#         print("格式错误请重新输入\n")
# flag = 1
# while flag != 0:
#     number = input("请输入手机号码\n")
#     if len(number) == 11:
#         flag = 0
#     else:
#         print("输入错误亲重新输入\n")
# flag = 1
# while flag != 0:
#     password = input("亲输入密码\n")
#     if password == '1234':
#         flag = 1
#         print("登录成功\n")
#     else:
#         print("密码错误亲重新输入\n")
# 账号正确输入验证码
import random
s = "qwertyuiopQWERTYUDFGHVBNMasdfghjxcvb1234567890PL"
print("--创建账号--")
username = input("亲输入账号")
flag = 0
while flag == 0:
    if username[0].isalpha() and len(username) > 5:
        flag = 1
    else:
        username = input("格式错误，不能以数字开头，长度大于5")
password = input("亲输入密码")
flag = 0
while flag != 2:
    if len(password) > 5:
        for i in range(len(password) - 1):
            if password[i].isalpha() and password[i+1].isdigit():
                flag = 2
    print("密码必须大于5且数字开头要包含字母")
    password = input("亲输入密码")
# denglu  不能数字开头 大于6为
print("登录")
name = input("亲输入账号\n")
flag = 0
while flag == 0:
    if name[0].isalpha() and len(name) >5:
        flag = 1
    else:
        name = input("格式错误，不能以数字开头，长度大于5")

pword = input("亲输入密码\n")
flag = 0
CATP = ''# 验证码
while flag == 0:
    if username == name:
        # 生成验证码
        for i in range(4):
            CATP += s[random.randint(0, len(s)-1)]
        print("验证码: "+CATP)
        catp = input("亲输入验证码\n")
        flag = 1
    else:
        print("账号和密码错误，亲重新输入\n")
        name = input("亲输入账号\n")
# 成功登录条件
flag = 0
while flag == 0:
    if username == name and password == pword and CATP == catp:
        print("登录成功\n")
        flag = 1
    elif CATP != catp:
        print("验证码错误,亲重新输入\n")
        for i in range(4):
            CATP += s[random.randint(0, len(s) - 1)]
        print("验证码: "+CATP)
        catp = input("亲输入验证码\n")
    elif username == name and password != pword and CATP == catp:
        print("账号或密码错误，亲重新输入\n")
        pword = input("亲输入密码\n")
# 字符串替换 replace("old","new","count") old->new
s = "hallo world good morning good evening good night"
result = s.replace("l","L",1)
print(result)
# 字符串分割操作 切好了放在列表里
# split rsplit splitlines partition rpartition
result = s.split(" ",6)# 最多切6次 剩下的就放一起
print(result)
result = s.rsplit(" ",3)# 从右边开始且
print(result)
s1 = ("incase i won't see you tomorrow
 good morning
 good evening
 and
 good night")
result = s1.split("\n")# 和splitlines 一个效果
print("there")
print(result)
print(s1)
print("here")
result = s1.splitlines()# 切割的是\n 无参数
print(result)
result = s1.partition("incase")# 将字符串分割成3部分储存在列表中 包括 指定字符前面的 指定字符 指定字符后面
print(result)
result = s1.rpartition("good")# 从右边开始
print(result)
# 修改大小写
# capitalize title upper lower
s = "this toy have abandoned for a week" + '\n' + "but it belong with me now"
result = s.title()# 每行的字母的首字母为转换为大写
print(result)
result = s.upper()# 全为大戏
print(result)
result = s.lower()# 全为小写
print(result)
result = result.capitalize()# 将字符串的首字母变为大写 其他转为小写
print(result)
# 处理空格
# strip lstrip rstrip
s = "   lllloooovvvvveeeeee       "
result = s.strip()# 去掉字符串俩边的空格
print(result)
result = s.rstrip()# 去掉右边的空格
print(result)
result = s.lstrip()# 去掉左边的空格
print(result)
# 调整字符串占位
# center ljust rjust
s = "CENTER"
result = s.center(9)# 将s居中对齐在指定的数中
print(result)
result = s.rjust(20)# 在指定的树中右对齐
print(result)
result = s.ljust(20)# 在指定的数中左对齐
print(result)
# 格式化：
# %d %f %s
# print("%d %f %s" % xxxx)
# format
name = "xiaoming"
age = 18
s = "{0} write down this node when he was {1}".format(name,age)# 一个写法
print(s)
s = "{name} pick up {money} yuan and spend {money} to buy a new book".format(name="xiaoming",money=20)
print(s)
s = "{name} spend {money} yuan to learn programmer and he feel full to some extent".\
    format(name="hadage", money=10000)
print(s)
#
a = hah
分割
for i in a:
    if i.isalpha():
        print(i.isalpha())

# 列表
arr = []
# 添加
arr.append("hahh")
arr.append(22)
arr.append('aaaa')
arr.append('aaaa')
print(arr)

arr.sort()
print(arr.count('aaaa'))
print(arr.index(22))
# 删除pop  remove del

arr.remove(22)
arr.pop()
print(arr)
arr.clear()
del arr# 吧指针指向得线给切短了

print(arr)
import random
arr = []

for i in range(10):
    arr.append(random.randint(1,100))
print(arr)
arr.sort()
print(arr)
arr.reverse()
print(arr)
arr.sort(reverse=False) # 升序
print(arr)
"""
# 冒泡
# arr = [2, 4, 1, 5]
import random

arr = []
for i in range(10):
    arr.append(random.randint(1, 100))
for i in range(len(arr)):
    flag = True
    for j in range(1, len(arr)-i):
        if arr[j-1] > arr[j]:
            tmp = arr[j-1]
            arr[j-1] = arr[j]
            arr[j] = tmp
            flag = False
    if flag:
        break
print(arr)








